#include ("/_includes/_layout.html")
#define css()
<link rel="stylesheet" type="text/css" href="#(webctx)/resources/css/product.css"/>
#end

#define script()
<script type="text/javascript" charset="utf-8" src="#(webctx)/resources/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="#(webctx)/resources/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="#(webctx)/resources/js/product/product.edit.js"></script>
#end
#@layout("商品管理", "wxmall,点步科技", "Wxmall社区","wxmall") 
#define content()
<form id="inputForm" action="#(webctx)/product/save" method="post">
<input type="hidden" name="id" value="#(product.id??)" class="form-control" />
<div class="wrapper wrapper-content">
	#include ("/_includes/menu-product.html")
	<div class="app-content">
	    <div class="row">
		   <div class="col-sm-12">
				<div class="tabs-container" style="background:#e5e5e5 " >
			        <ul class="nav nav-tabs" id="topNavTabs">
			            <li #if (!product!=null) class="active" #end><a href="javascript:void(0)" role="tab"  data-link="#js-step-1">1.选择分类</a></li>
			            <li #if (product!=null) class="active" #end><a href="javascript:void(0)" role="tab"  data-link="#js-step-2">2.基本信息</a></li>
			            <li><a role="tab" href="javascript:void(0)" data-link="#js-step-3">3.商品详情</a></li>
			        </ul>
			    </div>
	    
				<div class="tab-content  ibox-content">
				    <div id="js-step-1"  role="tabpanel" class="tab-pane #if(product ==null) active #end">
					      <div class="form-horizontal">
					          <div id="class-info-region" class="goods-info-group">
						        <div class="js-goods-klass">
						           <div class="class-block">
						                <div class="js-class-block control-group">
						                  <div class="controls">
								            <div class="widget-goods-klass">
								            #for(pcgory : productCategory)
								            	#if(pcgory.id?? !=0)
								            	<div class="widget-goods-klass-item #if( pcgory == product.productCategoryId??) current #end" category-id="#(pcgory.id??)" category-name="#(pcgory.name??)">
									                <span class="widget-goods-klass-name"> #(pcgory.name??) </span>    
									            </div>
									            #end
								            #end
								            <label id="assign_error_msg" style="color:red;"></label>
							                </div>
							               </div>
						                </div>
					                </div>
						        </div>
					      </div>
					    </div>
					    <div class="action-bar">
					      	<a href="#(webctx)/category" class="btn  btn-primary">创建分类</a>
					      	<button type="button"  onclick="goStepTwo();" class="btn  btn-primary">下一步</button>
					   	</div>
					</div>
					<div id="js-step-2"  role="tabpanel" class="tab-pane #if(product!=null) active #end">
					     <div id="base-info-region" class="form-horizontal">
					         <div class="goods-info-group-inner">
					             <div class="info-group-title">
									基本信息
								 </div>
								 <div class="info-group-content">
			                          <div class="form-group">
			                             <label class="col-md-2 control-label"><span class="requirespan">*</span>商品分类：</label>
			                             <div class="col-md-5">
				                          <div class="static-value" style="font-size: 14px;vertical-align: middle;line-height: 30px;"><span id="productCategoryName">#(categoryName)</span></div>
				                             <input type="hidden" value="#(product.product_category_id??)" id="productCategoryId" name="productCategoryId"/>
				                          </div>
			                          </div>
			                          
			                           <div class="form-group">
			                              <label class="col-md-2 control-label"><span class="requirespan">*</span>商品名：</label>
			                              <div class="col-md-4" id="error_product_name">
								                <input type="text" id="product_name"  name="name" value="#(product.name??)"  class="form-control"/>
								                <label class="control-label" for="product_name"></label>
								          </div>
			                          </div>
			                          
			                           <div class="form-group">
			                             <label class="col-md-2 control-label"><span class="requirespan">*</span>商品列表图：</label>
			                             <div class="col-md-5">
			                                 <div class="main-image-div">
			                                    #if(product != null)
			                                      <img class="image-preview" src="#(product.image)" >
		                                          <a class="close-modal small hide" href="javascript:void(0);" onclick="deleteMainImg();">×</a>
		                                          <input name="image" value="#(imgUrl)" type="hidden">
			                                    #else 
									                <a class="main-image-add" onclick="addPicture(true);" href="javascript:;" >+加图</a>
									            #end 
									           </div>
									           <p class="size-remark">建议尺寸：480*480像素 </p>
							                  <label id="only_error_msg" style="color:red;"></label>
								          </div>
			                           </div>
				                       
				                 </div>
					         </div>
					         
					         <div class="goods-info-group-inner">
					             <input type="hidden" id="allStocks"  name="stocks" value=""/>
					             <div class="info-group-title">
									库存/规格
								 </div>
								 <div class="info-group-content">
				                            <div class="form-group">
									            <label class="col-md-2 control-label"><span class="requirespan">*</span>规格设置</label>
									            <div class="col-md-8">
									                <div class="sign_list">
									                #if(product!=null)
									                <label class="radio-inline" for="inline-radio1">
				                                     <input id="checkbox4" name="is_unified_spec" class="frm_radio" value="true" onclick="changeType();" #if(product!=null && product.is_unified_spec) checked="checked" #end type="radio"/>
				                                      <span>统一规格</span>
				                         	        </label>
				                         	        <label class="radio-inline" for="inline-radio1">
				                                     <input id="checkbox4" name="is_unified_spec" class="frm_radio" value="false" onclick="changeType();" #if(product!=null && !product.is_unified_spec) checked="checked" #end type="radio"/>
				                                      <span>多规格</span>
				                         	        </label>
				                         	        #else
				                         	        <label class="radio-inline" for="inline-radio1">
				                                     <input id="checkbox4" name="is_unified_spec" class="frm_radio" value="true" onclick="changeType();" checked="checked" type="radio"/>
				                                      <span>统一规格</span>
				                         	        </label>
				                         	        <label class="radio-inline" for="inline-radio1">
				                                     <input id="checkbox4" name="is_unified_spec" class="frm_radio" value="false" onclick="changeType();" type="radio"/>
				                                      <span>多规格</span>
				                         	        </label>
									                #end
				                         	        </div>
				                         	     </div>
				                         	 </div>
				                          <div class="form-group" id="allSpec" >
				                             <label class="col-md-2 control-label"><span class="requirespan">*</span>商品规格：</label>
				                             <div class="col-md-10">
				                             <table class="table table-striped" style="font-size: 14px;">
				                              <tr>
				                              <td width="20%">选择规格</td>
								                 <td>
									               <div id="specificationSelect" class="specificationSelect">
														<ul id="specificationUl">
														#if(specificationResultDto !=null)
				                                           #for(ResultDto: specificationResultDto)
				                                           	   #if (ResultDto.specification !=null)
				                                           	   #for(specification : ResultDto.specification)
																	<li>
																		<label>
																			<input type="checkbox" name="specificationIds" value="#(specification.id)" #if(productAllResultDto!=null && productAllResultDto.specifications.contains(specification)) checked="checked" #end />#(specification.name)
																		</label>
																	</li>
															   #end
				                                           	   #end
					                                       #end
														#end
														<li><a href="javascript:;" onclick="addSpecification();" class="js-add-sku-atom add-sku" style="display: inline;">+添加规格</a></li>	
														</ul>																								    
									               </div>
									               </td>
									               </tr>
									               <tr>
									               <td>选择规格值
									               <label id="specificationValue_error_msg" style="color:red;"></label>
									               </td>
														<td>
															#if (product !=null)
															<table id="specificationProductTable" style="font-size: 14px;" class="table table-striped table-bordered">
															 <tbody id="specificationProductTbody">
															#if(specificationResultDto !=null)
															#for(ResultDto: specificationResultDto)
																#for(specification: ResultDto.specification)
															 	<tr class="specification_#(specification.id) #if(productAllResultDto && !productAllResultDto.specifications.contains(specification)) hidden #end">
																<td>	
																     <ul class="specificationSelect #if(productAllResultDto && productAllResultDto.specifications.contains(specification)) Father_Title #end" id="Title_#(specification.id)"> <li>#(specification.name)</li></ul>
															  	</td>
															  	<td>
										                        <ul class="Title_#(specification.id) Father_Item Item specificationSelect" id="Item_#(specification.id)">
										                        #for(specificationValue: ResultDto.specificationValues)
																	<li class="li_width">
																	<label>
																	<input type="checkbox" name="specificationValues" value="#(specificationValue.id)_#(specification.id)" data-value="#(specificationValue.id)" data-val="#(specificationValue.name)" #if(productAllResultDto && productAllResultDto.specificationValues.contains(specificationValue)) checked="checked" #end/>#(specificationValue.name)								
																	</label>
																	</li>
															    #end
															    </ul>
															   	</td>
																</tr>
															   	#end
										                   	#end
															#end
															</tbody>
															</table>
															#else
															<table id="specificationProductTable" style="font-size: 14px;" class="table table-striped table-bordered">
															<tbody id="specificationProductTbody">
															#if (specificationResultDto!=null)
															#for (ResultDto : specificationResultDto)
																#for(specification: ResultDto.specification) 
															<tr class="specification_#(specification.id) hidden">
																<td>	
																<ul class="specificationSelect" id="Title_#(specification.id)"> <li>#(specification.name)</li></ul>
															  	</td>
															  <td>
										                        <ul class="Title_#(specification.id) Father_Item Item specificationSelect" id="Item_#(specification.id)">
										                        #for(specificationValue : ResultDto.specificationValues)
																	<li class="li_width">
																	<label>
																	<input type="checkbox" name="specificationValues" value="#(specificationValue.id)_#(specification.id)" data-value="#(specificationValue.id)" data-val="#(specificationValue.name)"/>#(specificationValue.name)														
																	</label>
																	</li>
															    #end
															    </ul>
															   </td>
															</tr>
																#end
										                    #end
										                    #end
										                    </tbody>
															</table>
															#end
														</td>
													</tr>
													<tr>
													  <td>填写价格，库存</td>
													  <td id="createTable"></td>
													</tr>
									              </table>
									          </div>
				                          </div>
				                       
				                 </div>
					         </div>
					         <div class="goods-info-group-inner">
								 <div class="info-group-title">商品信息</div>
								 <div class="info-group-content">
				                     <div id="unified">
				                          <div class="form-group">
				                             <label class="col-md-2 control-label"><span class="requirespan">*</span>价格：</label>
				                              <div class="col-md-2" id="error_product_price">
												  <input type="text" id="product_price" name="price" value="#(product.price??)" class="form-control" onkeyup="checkNum(this);"/>
												   <label class="control-label" for="product_price"></label>
												</div>
				                          </div>
				                      
				                          <div class="form-group">
				                           <div class="row">
				                             <label class="col-md-2 control-label"><span class="requirespan">*</span>商品库存：</label>
				                              <div class="col-md-2" id="error_allStock">
									                <input type="text" id="allStock"  name="stock" value="#(product.stock??)" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'')"/>
									                 <label class="control-label" for="allStock"></label>
									          </div>
				                          </div>
				                          </div>
				                      </div>
				                      
			                          <div class="form-group">
			                             <label class="col-md-2 control-label"><span class="requirespan">*</span>上架：</label>
			                              <div class="col-md-2">
			                              <label>
												<input type="checkbox" name="isMarketable" value="true" #if(product!=null && product.isMarketable) checked="checked" #end/>是否上架
												<input type="hidden" name="_isMarketable" value="false" />
										  </label>
			                              </div>
			                          </div>
				                          
			                           <div class="form-group">
			                             <label class="col-md-2 control-label"><span class="requirespan">*</span>商品图：</label>
			                             <div class="col-md-10">
			                                 <ul class="app-image-list" id="product-image-list">
								                #if(productAllResultDto !=null)
												#for(images:productAllResultDto.imageList)
			                                    <li class="sort"><img src="#(images.imgPath)"  class="js-img-preview"/>
			                                    <input name="imgList" value="#(images.imgUrl)" type="hidden"  class="js-img-preview"/>
			                                    <a class="js-delete-picture close-modal small hide" onclick="deleteImg(this);">×</a>
			                                    </li>
			                                    #end					                
								                #end
								                 <li><a href="javascript:;" onclick="addImagList(false);" class="add-goods">+加图</a></li>
							                 </ul>
							                 <p class="size-remark">建议尺寸：640*480像素 </p>
							                 <label id="image_error_msg" style="color:red;"></label>
								          </div>
			                           </div>  
				                 </div>
					         </div>
					         
					         <div class="goods-info-group-inner">
					             <div class="info-group-title">
									物流/其它
								 </div>
								 <div class="info-group-content">
				                        <div class="form-group">
				                             <label class="col-md-2 control-label"><span class="requirespan">*</span>运费设置：</label>
				                              <div class="col-md-4">
				                              <label>
													<input id="js-unified-postage" name="delivery_type" value="0" #if(product!=null) #if(product.delivery_type==0) checked="checked" #end #else checked="checked" #end  type="radio" onclick="changeDelivertyType();">
													统一邮费 
									               <div class="input-group" style="margin-bottom: 0px;vertical-align: middle;display: inline-block;">
													  <input type="text" name="delivery_fees"  value="#(product.delivery_fees??0)" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'')"/>
													  <label class="delivery_fees_error_msg" style="color:red;"></label>
												   </div>
									          </label>
									          </div>
				                          </div>
				                          <div class="form-group">
				                             <label class="col-md-2 control-label"></label>
				                              <div class="col-md-6">
					                              <label>
														<input id="js-unified-postage" name="delivery_type" value="1" #if(product!=null && product.delivery_type==1) checked="checked" #end type="radio" onclick="changeDelivertyType();">
														运费模板
														<div class="delivery-template" style="display: inline-block;vertical-align: middle;">
														    <select class="form-control" name="delivery_template_id" id="delivery_memo">
														        <option value="#(deliveryTemplate.id??)"  data-type="#(deliveryTemplate.valuation_type??)">#(deliveryTemplate.name??)</option>
														    </select>
													   </div>
										               <div class="help-inline" style=" display: inline-block;padding-left: 5px;vertical-align: middle;">
										               <a class="js-refresh-delivery" href="javascript:;">刷新</a>
										               <span class="c-gray">|</span>
					                                   <a class="new-window" href="#(webctx)/delivery/add" target="_blank">新建</a>
										               </div>
										          </label>
										          <label class="delivery_template_error_msg" style="color:red;"></label>
									          </div>
				                          </div>
				                          
				                          <div class="form-group" id="weight_memo" style="display: none;">
				                             
				                              <div class="form-group">
				                                <label class="col-md-2 control-label"></label>
				                                <div class="col-md-6" style="color: #999999;">
				                                  <label> 当前运费模板，按物流重量（含包装）计费</label>
				                                </div>
				                              </div>
				                              <label class="col-md-2 control-label"></label>
				                              <div class="col-md-10">
				                                  <label class="control-label"><span class="requirespan">*</span>物流重量：</label>
				                                  <div class="input-group" id="unified_weight" style="margin-bottom: 0px;vertical-align: middle;display: inline-block;hidden">
													  <input type="text" id="delivery_weight" name="delivery_weight"  value="#(product.delivery_weight??)" class="control-inline" max-length="10" style="width:80px;"  onkeyup="value=value.replace(/[^\d.]/g,'')"/> 千克
													  <label class="delivery_weight_error_msg" style="color:red;"></label>
												  </div>
												  
												  <div class="input-group" id="disunified_weight" style="margin-bottom: 0px;vertical-align: middle;display: inline-block;hidden">
													  <div id="createdWeight"></div>
												  </div>
												  
				                              </div>
				                          </div>
				                       
				                  </div>
				              </div>
					     </div>
						
					    <div class="action-bar">
						  <button type="button"  onclick="backStepOne();" class="btn btn-default">上一步</button>
					      <button type="button"  onclick="goStepThree();" class="btn  btn-primary">下一步</button>
					   </div>
					   
					</div>
					
					<div id="js-step-3"  role="tabpanel" class="tab-pane">
				     <div id="step-content-region" style="padding-top: 20px;">
						 <div class="app-sidebar-inner js-sidebar-region" style="width: 396px; z-index: 1;padding-top: 20px;">    
						   <script type="text/plain" id="editor"  name="introduction"></script>
						 </div>		 
				     </div>
				     
				     <div class="action-bar">
				      	<button type="button"  onclick="backStepTwo();" class="btn btn-default">上一步</button>
				       	<button type="button" onclick="saveProductForm();"  class="btn  btn-primary">保存商品</button>
				   	</div>
				 </div>
				</div>		
	       </div>
	       
	       <!-- <div class="col-sm-2">
			    <div class="wrapper-content project-manager">
			        <h4>帮助说明</h4>
			        <ol>
			            <li>第一步：选择商品分类</li>
			            <li>第二步：填写商品基本信息</li>
			            <li>第二步：填写商品详细信息</li>
			            <li>商品规格如何新建:操作路径：微商城，左侧导航，商品－规格－添加规格后：出现在商品基本信息《库存/规格》的多规格里</li>
			        </ol>
			    </div>
			</div>	 -->
		</div>	
	</div>
</div>
</form>
<script type="text/template" id="specification_li_tpl">
<li><label><input type="checkbox" name="specificationIds" value="{id}"/>{name}</label></li>
</script>
<script type="text/template" id="specificationValue_tr_tpl">
<tr class="specification_{id} hidden">
	<td><ul class="specificationSelect" id="Title_{id}"> <li>{name}</li></ul></td>
	<td><ul class="Title_{id} Father_Item Item specificationSelect" id="Item_{id}"></ul></td>
</tr>
</script>

<script type="text/template" id="specificationValue_li_tpl">
<li class="li_width">
	<label><input type="checkbox" name="specificationValues" value="{id}_{specification_id}" data-value="{id}" data-val="{name}"/>{name}</label>
</li>
</script>
<script type="text/template" id="ul_li_tpl">
    <li data-file="{filePath}" data-fileUrl="{fileName}">
       <img alt="" src="{filePath}">
       <div class="image-title">{fileName}</div>
    </li>
</script>
#end
<script type="text/javascript">
var listImg="";	
var listImgUrl="";
var listUpload="";
var g_spec_type="";
var catagory="#(product.product_category_id??)";
var selectImg = new Array();
#if (product!=null)
var productId = '#(product.id)';
var  curActive="#js-step-2";
#else
var  curActive="#js-step-1";
#end

function getPrice(){
	#if (productAllResultDto!=null)
		#for(stock : productAllResultDto.stocks) 
	  	$("#priceId"+"#(stock_index)").val(#(stock.price)); 
	  	$("#stockId"+"#(stock_index)").val(#(stock.stock));
	  	$("#weightId"+"#(stock_index)").val(#(stock.weight));
	  	#end
	#end
}
	
var ue = UE.getEditor('editor',{
	toolbars: [
				["bold", "italic", "underline", "strikethrough", "forecolor", "backcolor", "justifyleft", "justifycenter", "justifyright", "|", "insertunorderedlist", "insertorderedlist", "blockquote",
				"simpleupload", "insertimage", "insertvideo", "link", "removeformat", "|", "rowspacingtop", "rowspacingbottom", "lineheight", "paragraph", "fontsize",
				"inserttable", "deletetable", "insertparagraphbeforetable", "insertrow", "deleterow", "insertcol", "deletecol", "mergecells", "mergeright", "mergedown", "splittocells", "splittorows", "splittocols"]
			],
			autoClearinitialContent: false,
			enableAutoSave: false,
			autoFloatEnabled: !0,
			wordCount: !1,
			elementPathEnabled: !1,
			initialContent:'#(product.introduction??)',
  		/* 	initialFrameWidth: 396, */
			initialFrameHeight: 350, 
			focus: !1,
			pasteplain: !1
});
</script>
